import './style/forwardback.less';
import React from 'react';
import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx';
import { withRouter } from 'react-router-dom';
import { RouteLayout } from 'weaver-mobile-page';
import { Bubble,List,Radio,Tools } from 'weaver-mobile';
import { ListPage } from 'weaver-mobile-page';
const getLabel = Tools.getLabel;

const ButtonGroup = RouteLayout.ButtonGroup;

@inject('wfForwardBackStore')
@withRouter
@observer
export default class ForwardBack extends React.Component {

    componentDidMount() {
        this.getBottomBtn.bind(this);
        const {params={},wfForwardBackStore,location={}} =this.props;
        const para = {requestId:params.requestid,fromMobile:1}
        wfForwardBackStore.getLogDatas(para);
        wfForwardBackStore.setCallBack(location.callback);
    }

    render() {
        const { wfForwardBackStore } = this.props;
        const {listStore,listDatas,setSelectDatas,template } = wfForwardBackStore;
        return (
            <div className={'forwardback'}>
                <ListPage.Normal
                    showCheck
                    template={template}
                    store={listStore}
                    multipleCheck={true}
                    onRowSelect={(...arg) => {
                        setSelectDatas(arg[0]);
                    }}
                />
                <div style={{position:"absolute", bottom:"0",width:"100%"}}>
                    <ButtonGroup  data={this.getBottomBtn()} />
                </div>
            </div>
        );
    }

    getBottomBtn(){
        const {wfForwardBackStore} =this.props;
        const { selectRow=[] } = wfForwardBackStore;
        return [{
                key: 'sure',
                text: getLabel('826','确定'),
                onClick: ()=>{
                    if(toJS(selectRow).length >0){
                        wfForwardBackStore.doForwardBack();
                    }

                },
                className : toJS(selectRow).length  == 0 ? 'disabled' : 'abled'
            },
        ];
    }
}

